<template>
  <div class="deploy-guide">
    <div class="guide-header">
      <h3>部署指南</h3>
      <div class="actions">
        <el-tooltip content="复制全部" placement="top">
          <el-button 
            type="primary" 
            plain 
            size="small" 
            class="action-button"
            @click="copyGuide"
          >
            <el-icon><DocumentCopy /></el-icon>
            <span>复制指南</span>
          </el-button>
        </el-tooltip>
      </div>
    </div>
    
    <div class="guide-content">
      <markdown-renderer :content="guide" />
    </div>
    
    <!-- 复制成功提示 -->
    <el-notification
      v-model="showCopyNotification"
      title="复制成功"
      type="success"
      :duration="2000"
    >
      <span>部署指南已复制到剪贴板</span>
    </el-notification>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import MarkdownRenderer from './MarkdownRenderer.vue';
import { DocumentCopy } from '@element-plus/icons-vue';

// 接收的属性
const props = defineProps({
  guide: {
    type: String,
    default: ''
  }
});

// 复制通知
const showCopyNotification = ref(false);

// 复制部署指南
const copyGuide = async () => {
  try {
    await navigator.clipboard.writeText(props.guide);
    showCopyNotification.value = true;
    
    setTimeout(() => {
      showCopyNotification.value = false;
    }, 2000);
  } catch (error) {
    console.error('复制失败:', error);
    // 可以添加失败提示
  }
};
</script>

<style scoped>
.deploy-guide {
  margin: 20px 0;
  padding: 20px;
  background-color: #f9f9f9;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.3s ease;
}

.deploy-guide:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.guide-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ebeef5;
}

.guide-header h3 {
  margin: 0;
  font-size: 20px;
  color: #303133;
  font-weight: 600;
}

.guide-content {
  background-color: white;
  border-radius: 8px;
  padding: 24px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}
</style> 